$(document).ready(function() {
	$( "#datetime" ).datepicker();
	$( "#datetime" ).datepicker( "option",$.datepicker.regional[ 'zh-CN'] );
	
	$( "#lastDate" ).datepicker();
	$( "#lastDate" ).datepicker( "option",$.datepicker.regional[ 'zh-CN'] );
	
	$("#deleteBackupFile").click(function(){
		if($("#lastDate").val()==""){
			alert("请输入日期");
			return;
		}
		$("#deleteMessage").html("正在删除,请稍后...");
		$.getJSON(getRootPath()+ "/MainMenu/configuration/deleteBackupFiles.htm",{dateTime:$("#lastDate").val()},function(data){
			if(data.error==undefined){
				$("#deleteMessage").html("删除成功");
			}else{
				$("#deleteMessage").html("无对应文件，或者没有权限，删除失败");
			}
		});
	});
	
	$("#backUpOldMember").click(function(){
		if($("#datetime").val()==""){
			alert("请输入日期");
			return;
		}
		$("#oldMemberOperateMessage").html("正在转存,请稍后...");
		$.getJSON(getRootPath()+ "/MainMenu/configuration/deleteOldMemberData.htm",{dateTime:$("#datetime").val()},function(data){
			if(data.error==undefined){
				$("#oldMemberOperateMessage").html("转存成功");
			}else{
				$("#oldMemberOperateMessage").html("转存失败");
			}
		});
	});
});

function restore(fileName){
	$( "#progressbar" ).progressbar({
		value: 100,
		modal:true
	});
	$("#fileName").val(fileName);
	$("#progressbar").dialog("open");
	$.getJSON(getRootPath()+ "/MainMenu/configuration/restore.htm",$("#restoreForm").serializeArray(),function(data){
		$( "#progressbar" ).progressbar("destroy");
		alert(data.message);
	});
}

function stopBackup(){
	$("#stopBackupForm").submit();
}

